% read
load matrix.txt

n = size(matrix);

% normalize
for i=1:n(1)
    matrix(i,:)=matrix(i,:)./norm(matrix(i,:));
end

cosD = matrix*matrix';
format;

%dlmwrite('cosine distance.txt', cosD, '\t');
dlmwrite('cosine distance.txt', cosD, 'delimiter', ' ', 'precision', '%1.9f');

%save('cosine distance.txt','cosD','-ascii');

%fid=fopen('cosine distance.txt','wt');
%fprintf(fid,'%g',cosD);
%fclose();
